package com.code.day10.Socketz;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(6666);
        Socket socket = serverSocket.accept();
        InputStream inputStream = socket.getInputStream();
        byte[] buffer = new byte[1024];
        int len = inputStream.read(buffer);

        System.out.println(new String(buffer, 0, len));
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("返回数据给CLIENT".getBytes());

        outputStream.close();
        inputStream.close();
        socket.close();
        serverSocket.close();
    }
}
